package main

import (
	"time"
)

// User 用户表映射
type User struct {
	Phone    string `gorm:"primary_key;column:phone;type:varchar;size:13"`
	Password string `gorm:"column:password;type:varchar;size:32"`
}

// TableName 设置User的表名为`t_user`
func (User) TableName() string {
	return "t_user"
}

// BookKind 图书类型表映射
type BookKind struct {
	ID   uint   `gorm:"primary_key"`
	Name string `gorm:"type:varchar;size:50"`
}

// TableName 设置BookKind的表名为`t_book_kind`
func (BookKind) TableName() string {
	return "t_book_kind"
}

// BookInfo 图书信息表映射
type BookInfo struct {
	ID                uint      `gorm:"primary_key"`
	Name              string    `gorm:"type:varchar;size:100"`
	Author            string    `gorm:"type:varchar;size:50"`
	AuthorNationality string    `gorm:"column:author_nationality;type:varchar;size:20"`
	Publisher         string    `gorm:"type:varchar;size:50"`
	PublicationTime   time.Time `gorm:"column:publication_time"`
	Price             float32   `gorm:"type:decimal;size:10"`
	Summary           string    `gorm:"type:text"`
	KindID            int       `gorm:"column:kind_id"`
	Picture           string    `gorm:"column:picture"`
	Remaining         uint
	CreateTime        time.Time `gorm:"column:create_time"`
}

// TableName 设置BookInfo的表名为`t_book_info`
func (BookInfo) TableName() string {
	return "t_book_info"
}
